<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <link rel="stylesheet" href="../../js/wu_qi/bootstrap/css/bootstrap.min.css">
  <script src="../../js/wu_qi/bootstrap/js/jq.mini.js"></script>
  <script src="../../js/wu_qi/bootstrap/js/bootstrap.min.js"></script>
  <link rel="stylesheet" href="../../css/wu_qi/reset.css">
  <script src="../../js/wu_qi/Flow.js"></script>
  <style>
    .header {
      padding: 20px 50px;
      height: 100%;
      font-size: 16px;
    }

    .header .header_title {
      font-size: 20px;
      height: 30px;
      line-height: 30px;
    }

    .header_list {
      border-top: 1px solid #1561;
      display: flex;
      padding-top: 10px;


    }


    .center .row {
      display: flex;
    }


    .center {
      margin: 20px 0px;
      padding: 25px 0px;
      background-color: rgb(247, 247, 247);

    }

    .center .mb-3 {
      margin-bottom: 0rem !important;
    }

    .center .header_input {
      width: 280px;
      height: 30px;
      padding: 0px 10px;
      margin: 0px 10px;
      background-color: rgba(255, 255, 255, 1);
      border: 1px solid rgba(217, 217, 217, 1);
      border-radius: 4px;
      box-sizing: border-box;
      color: rgb(78, 78, 78);
    }

    .header_input_title {
      padding: 0px 5px;
      text-align: center;
      line-height: 30px;
    }

    .center_title,
    .center_title_Processing {
      display: flex;
    }

    .grade_option {
      padding: 5px 60px;
      margin-left: 10px;
    }

    .right {
      display: flex;
      justify-content: flex-end;
    }

    .center_list_ul {
      margin-top: 20px;
      display: flex;
      flex-direction: row;
      color: #666666;
    }

    .header .center_list_ul li {
      flex: 1;
      width: 125px;
      height: 50px;
      text-align: center;
      line-height: 35px;
      border: 1px solid rgba(217, 217, 217, 1);
      background-color: rgba(244, 244, 244, 1);
    }

    .headerPage ul {
      display: flex;
    }

    .headerPage ul li {
      flex: 1;
      width: 125px;
      height: 50px;
      text-align: center;
      line-height: 35px;
    }

    .list_checkbox {
      display: flex;
      justify-content: space-evenly;
    }

    .page {
      display: inline-block;
      width: 30px;
      height: 30px;
      line-height: 30px;
      text-align: center;
      background-color: rgb(255, 255, 255);
      margin: 3px 5px;
      cursor: pointer;
      border-radius: 10%;
    }

    .active {
      background-color: rgba(25, 158, 216, 1);
      color: aliceblue;
    }

    .fooler {
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
    }

    .suju {
      font-size: 18px;
    }
  </style>
</head>

<body>
  <div class="container-fluid header">
    <div class="header_title">
      等级升级审核
      <hr>
    </div>
    <div class="center">
      <div class="row">
        <div class="col-lg-4 col">
          <div class="input-group input-group-sm mb-3 center_title_Processing">
            <div class="header_input_title">处理状态</div>
            <!-- Single button -->
            <div>
              <div class="form-group">
                <select id="grade" class="form-control grade_option Processing">
                  <option value="0">审核状态</option>
                  <option value="待审核">待审核</option>
                  <option value="已完成">已完成</option>
                  <option value="已拒绝">已拒绝</option>
                </select>
              </div>
            </div>

          </div>
        </div>
        <div class="col-lg-3 col">
          <div class="input-group input-group-sm mb-3 center_title_Processing">
            <div class="header_input_title">会员等级</div>
            <!-- Single button -->
            <div>
              <div class="form-group">
                <select id="grade" class="form-control  grade_option level">
                  <option value="0">会员等级</option>
                  <option value="A">A</option>
                  <option value="B">B</option>
                  <option value="C">C</option>
                  <option value="D">D</option>
                </select>
              </div>
            </div>

          </div>
        </div>
        <div class="col-lg-1">

          <button type="button" class="btn btn-primary search">搜索</button>
        </div>
      </div>
    </div>
    <div class="grade_selectAll">
      <div class="row">
        <div class="col col-lg-8 left">
          <div class="row">
            <div class="form-check col col-lg-2">
              <input class="form-check-input listAll" type="checkbox" value="" id="flexCheckDefault">
              <label class="form-check-label" for="flexCheckDefault">
                全选
              </label>
            </div>

            <div class="left_two col ">
              <button type="button" class="btn btn-primary ProcessTrue">审核通过</button>
              <button type="button" class="btn btn-primary " data-bs-toggle="modal" data-bs-target="#staticBackdrop">
                审核拒绝
              </button>

            </div>
          </div>

        </div>
        <div class="col col-lg-4 right">共
          <div class="suju"></div>
          条信息
        </div>
      </div>
    </div>
    <div class="grade_list">
      <div class="center_list">
        <ul class="list-group center_list_ul">
          <li class="list-group-item">审核ID</li>
          <li class="list-group-item">用户邀请码</li>
          <li class="list-group-item">现等级</li>
          <li class="list-group-item">升级等级</li>
          <li class="list-group-item">申请时间</li>
          <li class="list-group-item">处理时间</li>
        </ul>
        <div class="headerPage ">
        </div>
        <div class="fooler">
          <nav aria-label="Page navigation example">
            <ul class="pagination">
              <div class="clear pageDiv">
                <span class="page active">1</span>
                <span class="page">1</span>
              </div>
            </ul>
          </nav>
        </div>
      </div>
    </div>
    <!-- Modal -->
    <div class="modal fade" id="staticBackdrop" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1"
      aria-labelledby="staticBackdropLabel" aria-hidden="true">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
          </div>
          <div class="modal-body">
            是否确认审核拒绝？
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">关闭</button>
            <button type="button" class="btn btn-primary ProcessFalse">确认</button>
          </div>
        </div>
      </div>
    </div>

  </div>
  <script>
    //全局声明
    let searchArr = []
    let toPage = []
    let maxPage
    let to = 1
    var myDate = new Date();
    let delId;
    search()
    $(".suju").text(flow.length)

    function show(data) {
      $(".headerPage").html("")
      for (let i = 0; i < data.length; i++) {
        $(".headerPage").append(`
                 <ul>
                    <li class="list-group-item list_checkbox ">
                         <input  name="check" class="form-check-input listAllBox" type="checkbox" value="" id="flexCheckDefault">    
                        ${data[i].num}
                        </li>
                    <li class="list-group-item">${data[i].user}</li>
                    <li class="list-group-item">${data[i].level}</li>
                    <li class="list-group-item">${data[i].toLevel}</li>
                    <li class="list-group-item">${data[i].Time}</li>
                    <li class="list-group-item time">----</li>
                   
                `)

      }
    }
    // 分页 每页7页
    function showData(data, pageNum) {
      let toS = (pageNum - 1) * 7
      toPage = data.slice(toS, toS + 7)
      show(toPage)
      $(".page").eq(pageNum - 1).addClass("active").siblings().removeClass("active")
      to = pageNum
    }

    function showPage(data) {
      maxPage = Math.ceil(data.length / 7)
      $(".pageDiv").html("")
      for (let i = 1; i <= maxPage; i++) {
        $('.pageDiv').append(`<span class="page">${i}</span>`)
      }
    }
    $('.pageDiv').on('click', '.page', function () {
      showData(searchArr, parseInt($(this).text()))
    })
    $(".search").click(function () {
      search()
    })

    function search() {
      let Processing = $(".Processing option:selected").val()
      let level = $(".level option:selected").val()

      console.log(Processing, level);
      searchArr = [...flow]
      console.log(searchArr);

      if (Processing != 0) {
        for (let i = 0; i < searchArr.length; i++) {
          if (searchArr[i].Processing != Processing) {
            searchArr.splice(i, 1)
            i--
          }
        }
      }
      if (level != 0) {
        for (let i = 0; i < searchArr.length; i++) {
          if (searchArr[i].level != level) {
            searchArr.splice(i, 1)
            i--
          }

        }
      }
      console.log(searchArr);
      showPage(searchArr)
      showData(searchArr, 1)
    }

    function time() {
      for (let i = 0; i < flow.length; i++) {
        if (flow[i].ProcessTime == true) {
          $(".time").text(myDate.toLocaleDateString())
        }
      }
    }
    time()
    //全选
    $(".listAll").click(function () {
      $(".listAllBox").prop("checked", true)
    })
    //审核通过
    $(".ProcessTrue").click(function () {
      time()
    })
    //审核未通过
    $(".ProcessFalse").click(function () {
      for (let i = 0; i < flow.length; i++) {
        flow[i].ProcessTime = false
        $(".time").text("未通过")
      }
    })
  </script>
</body>

</html>